package org.example.test.util;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

public class RabbitMQUtils {
    public static Channel getChannel() throws Exception{
        // 创建连接工厂
        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost("192.168.2.121");
        factory.setUsername("admin");
        factory.setPassword("123");
        factory.setVirtualHost("my_vhost");
        Connection connection = factory.newConnection();// 创建连接
        Channel channel = connection.createChannel();// 创建通道
        return channel;
    }
}
